<template>
  <div class="detail-cart">
    <div class="top">
      <div class="imgs">
      <img :src="info.primary_pic_url" alt="" />
      </div>
      <div class="top-right">
        <p class="price">{{ info.retail_price | priceFilter }}</p>
        <p class="count">请选择数量</p>
      </div>
    </div>
    <div class="bottom">
      <p>数量</p>
      <div class="bottom-main">
        <div @click="decrementClick" :disabled="count <= 1">-</div>
        <div class="input" >{{count}}</div>
        <!-- <input type="text" /> -->
        <div @click="incrementClick">+</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    info: {
      type: Object,
      default() {
        return {};
      },
    }, 
  },
  data() {
    return {
      count: 1
    }
  },
  methods: {
    incrementClick() {
      this.count++
      this.$store.commit('addCouuntCart');
      this.$emit('incrementClick', this.count)
    },
    decrementClick() {
      
      if (this.count > 1) {
        this.count--
      }
      console.log(this.count)
      this.$emit('decrementClick', this.count)
    }
  },
  filters: {
    priceFilter(val) {
      return "价格¥" + val;
    },
  },
};
</script>

<style lang="scss" scoped>
// 88.5
.detail-cart {
  padding: 10px 10px;
  .top {
    display: flex;
    margin-bottom: 20px;
    .imgs {
      width: 88px;
      margin-right: 20px;
      img {
        width: 100%;
      }
    }
    .top-right {
      .price {
        color: #b4282d;
        margin: 20px 0;
      }
      .count {
        margin-top: 10px;
      }
    }
  }
  .bottom {
    p {
      margin: 5px 0;
    }
    .bottom-main {
      display: flex;
      .input {
        margin: 0 5px;
        color: #333;
      }
      // .input {
      //   box-sizing: border-box;
      //   width: 0.85333rem;
      //   height: 0.74667rem;
      //   margin: 0 0.05333rem;
      //   padding: 0;
      //   color: #323233;
      //   font-size: 0.37333rem;
      //   line-height: normal;
      //   text-align: center;
      //   vertical-align: middle;
      //   background-color: #f2f3f5;
      //   border: 0;
      //   border-width: 0.02667rem 0;
      //   border-radius: 0;
      //   -webkit-appearance: none;
      // }
      div {
        width: 28px;
        height: 28px;
        text-align: center;
        line-height: 28px;
        background-color: #f4f4f4;
        font-size: 16px;
        color: #626264;
      }
    }
  }
}
</style>